program define mclogit_lf
args lnf xb a0 a1
tempvar prob

#delimit ;
quietly generate double `prob' = cond($ML_y1==1, 
	normal(`a0')+(1-normal(`a0')-normal(`a1'))*logistic(`xb'), 
	1-normal(`a0')-(1-normal(`a0')-normal(`a1'))*logistic(`xb') ) 
	if $ML_samp==1;
#delimit cr

if normal(`a0')+normal(`a1') < 1 {
	quietly replace `lnf' = ln(`prob')
}
else {
	qui replace `lnf'=.
}

end
